﻿using System.Web.Mvc;

namespace RHD.Common.Web.Utility.Extensions {
	public static class HtmlHelperExtension {

		public static string GetFullHtmlFieldName(this HtmlHelper htmlHelper, string valueId) {
			return GetFullHtmlFieldName(htmlHelper.ViewContext.ViewData.TemplateInfo, valueId);
		}

		public static string GetFullHtmlFieldName(TemplateInfo templateInfo, string valueId) {
			return templateInfo.GetFullHtmlFieldName(valueId).Replace(".[", "[");
		}

		public static string GenerateIDFromName(string name) {
			TagBuilder builder = new TagBuilder("input");
			builder.GenerateId(name);
			return builder.Attributes["id"];
		}
	}
}